package com.zm.demo.core.concurrent;

import static java.lang.System.out;

/**
 * Created by Administrator on 2020/2/29.
 */
public class DeadLock {

    public static void main(String[]args){

        String source1= "source1";
        String source2= "source2";
        Thread t1 = new Thread(()->{
            synchronized (source1){
                out.println("t1 lock " + source1);
                synchronized (source2){
                    out.println("t1 lock " + source2);
                }
            }
        });

        Thread t2 = new Thread(()->{
            synchronized (source2){
                out.println(" t2 lock " + source2);
                synchronized (source1){
                    out.println("t2 lock " + source1);
                }
            }
        });

        t1.start();
        t2.start();


    }
}
